package ro.k.servlets.order;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import ro.k.tags.ReqManopera;
import ro.k.tags.ReqPiese;
import ro.k.web.beans.order.ReqManoperaBean;
import ro.k.web.beans.order.ReqPiesaBean;

/**
 * Servlet implementation class AddReqPiesa
 */
@WebServlet("/addReqPiesa")
public class AddReqPiesa extends HttpServlet {
	private static final long serialVersionUID = 1L;       
    public AddReqPiesa() {
        super();
    }

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		HttpSession sess = request.getSession();

		String pg = request.getParameter("pagina");
		String cantitate = request.getParameter("cantitate").toString();
		String nume = request.getParameter("nume").toString();
		String stare = request.getParameter("stare").toString();

		ReqPiese tagReqMan = (ReqPiese) sess.getAttribute("tagReqPiese");
		
		ReqPiesaBean rpb = new ReqPiesaBean(nume, Double.valueOf(cantitate), stare);
		
		tagReqMan.addReqPiesa(rpb);

		response.sendRedirect(request.getContextPath() + "/jsp/" + pg);
	}

}
